package com.huitone.smspfm.socket.core;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.huitone.smspfm.socket.protocol.sgip.message.Message;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.ActiveTest;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.ActiveTestResp;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Bind;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.BindResp;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Deliver;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.DeliverResp;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Report;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Report2;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Report2Resp;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.ReportResp;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Submit;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Submit2;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Submit2Resp;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.SubmitResp;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.UnBind;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.UnBindResp;
import com.huitone.smspfm.socket.protocol.sgip.message.msghead.Head;

/**   
* @Title AbstractMessageHandler.java 
* @Package com.huitone.smspfm.socket.core 
* @Description TODO(用一句话描述该文件做什么) 
* @author ybliang   
* @date 2017年4月12日 上午10:07:59 
* @version V1.0   
*/
public class AbstractMessageHandler implements IMessageHandler {
	
	private static Logger logger = LogManager.getLogger(AbstractMessageHandler.class);
	
	protected ExecutorService executorService = Executors.newFixedThreadPool(30);
	
	@Override
	public void handleBindMessage(Head head, Bind body, SocketHolder socketHolder) {
		logger.info(new Message(head, body));
	}

	@Override
	public void handleBindRespMessage(Head head, BindResp body) {
		logger.info(new Message(head, body));
	}

	@Override
	public void handleSubmitMessage(Head head, Submit body, SocketHolder socketHolder) {
		logger.info(new Message(head, body));
	}

	@Override
	public void handleSubmitRespMessage(Head head, SubmitResp body) {
		logger.info(new Message(head, body));
	}

	@Override
	public void handleDeliverMessage(Head head, Deliver body, SocketHolder socketHolder) {
		logger.info(new Message(head, body));
	}

	@Override
	public void handleDeliverRespMessage(Head head, DeliverResp body) {
		logger.info(new Message(head, body));
	}

	@Override
	public void handleReportMessage(Head head, Report body, SocketHolder socketHolder) {
		logger.info(new Message(head, body));
	}

	@Override
	public void handleReportRespMessage(Head head, ReportResp body) {
		logger.info(new Message(head, body));
	}

	@Override
	public void handleUnBindMessage(Head head, UnBind body, SocketHolder socketHolder) {
		logger.info(new Message(head, body));
	}

	@Override
	public void handleUnBindRespMessage(Head head, UnBindResp body) {
		logger.info(new Message(head, body));
	}

	@Override
	public void handleActiveTestMessage(Head head, ActiveTest body, SocketHolder socketHolder) {
		logger.info(new Message(head, body));
	}

	@Override
	public void handleActiveTestRespMessage(Head head, ActiveTestResp body) {
		logger.info(new Message(head, body));
	}

	@Override
	public void handleSubmit2Message(Head head, Submit2 body, SocketHolder socketHolder) {
		logger.info(new Message(head, body));
	}

	@Override
	public void handleSubmit2RespMessage(Head head, Submit2Resp body) {
		logger.info(new Message(head, body));
	}
	
	@Override
	public void handleReport2Message(Head head, Report2 body, SocketHolder socketHolder) {
		logger.info(new Message(head, body));
	}

	@Override
	public void handleReport2RespMessage(Head head, Report2Resp body) {
		logger.info(new Message(head, body));
	}
	
	public ExecutorService getExecutorService() {
		return executorService;
	}

	public AbstractMessageHandler setExecutorService(ExecutorService executorService) {
		this.executorService = executorService;
		return this;
	}

	public void reload() {
		
	}

	public void shutdown() {
		
		if (executorService != null) {
			executorService.shutdown();
			executorService = null;
		}
		
	}
}
